<template>
	<view class="page">
		<view class="feedback-body">
			<textarea auto-focus="true" placeholder="写下您投诉的理由(字数20~150)..." v-model="content" class="feedback-textare" />
		</view>
		<view class="input-view">
			您好，收到您的投诉之后，我们将告知对方被投诉，我们平台会给你们双方24小时的时间去协商处理，在此时间内您有权撤销投诉；24小时后未撤销投诉，我们平台会给予相应的处理结果
		</view>
		
		<button type="primary" class="feedback-submit" @tap="send">提交</button>
	</view>
</template>

<script>
	import {
		addComplain
	} from '@/api/ucenter/index';
	import {mapGetters} from 'vuex';
	export default {
		data: {
			content:"",
			partyId: ""
		},
		onUnload(){
			this.imageList = [];
			this.content = ""
		},
		onLoad(e) {
			this.partyId = e.partyId;
		},
		computed: {
			...mapGetters(['userId'])
		},
		methods: {
			
			send() { //发送反馈
				if(this.content.length <=0 ||this.content.length < 20) {
					uni.showModal({
						title:"提示",
						content:"请至少输入20个字的描述，谢谢"
					})
					return;
				}
				let complain = {
					complainPartyId: this.partyId,
					complainContent: this.content,
					statusId: 'COMPLAIN_CHECK'
				}
				
				addComplain(complain).then(response => {
					if(response.status == 200 && response.rel == true) {
						uni.showModal({
							title: "提示",
							content: "对于您的投诉诉求，我们已经受理，我们将通知对方在24小时之内与您联系，谢谢",
							success: async function(){
								uni.navigateBack()
							}
						})
					} else {
						uni.showModal({
							title: "提示",
							content: "提交失败，请重试，谢谢",
							success: async function(){
								uni.navigateBack()
							}
						})
					}
				}).catch(err =>  {
					uni.showModal({
						title: "提示",
						content: "提交失败，请重试，谢谢",
						success: async function(){
							uni.navigateBack()
						}
					})
				});
			}
		}
	}
</script>

<style>
	page {
		background-color: #EFEFF4;
	}

	.input-view {
		font-size: 28px;
	}
	
		
		.feedback-submit {
			background: #7C4BF9 !important;
		}
</style>
